﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DTO;
using DAL;
namespace BUS
{
   public class TINH_TPBUS
    {
        public static void Insert(TINH_TP category)
        {
            TINH_TPDAL categoryDAL = new TINH_TPDAL();
            categoryDAL.Insert(category);
        }
        public static void Update(TINH_TP category)
        {
            TINH_TPDAL categoryDAL = new TINH_TPDAL();
            categoryDAL.Update(category);
        }
        public static void Delete(int Ma_tinh)
        {
            TINH_TPDAL categoryDAL = new TINH_TPDAL();
            //categoryDAL.Delete(iD);
            categoryDAL.Delete(Ma_tinh);
        }
        public static tinh_tpColection GET(string Where, int PageIndex, int PageSize,
                                         string OrderBy, string OrderDirection,
                                         out int TotalRecords)
        {
            TINH_TPDAL categoryDAL = new TINH_TPDAL();
            return categoryDAL.GET(Where, PageIndex, PageSize, OrderBy, OrderDirection, out TotalRecords);
        }
        public static TINH_TP GetByID(int iD)
        {
            int t = 0;
            TINH_TPDAL ttpDAL = new TINH_TPDAL();
            tinh_tpColection ttpColection = ttpDAL.GET("where " + tinh_tpColumns.Ma_tinh.ToString() + " = " + iD.ToString(), 0, 0,
               tinh_tpColumns.Ten_tp.ToString(), "ASC", out t);
            if (ttpColection.Count == 1)
                return ttpColection[0];
            return null;
        }

        public static tinh_tpColection GetAll()
        {
            int t = 0;
            TINH_TPDAL ttpDAL = new TINH_TPDAL();
            return ttpDAL.GET("where 1=1", 0, 10, tinh_tpColumns.Ten_tp.ToString(), "ASC", out t);
        }
    }
}
